package com.yunhe.authority.repository.paymentInfo;

import com.yunhe.authority.domain.company.OtherCost;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @ClassName: OtherCostRepository
 * @Description:
 * @author: GongDaCheng
 * @Date: 11:19 2021/7/16
 */
@Repository
public interface OtherCostRepository extends Neo4jRepository<OtherCost, Long> {

    /**
     * @Description 根据企业id查询企业缴费其他费用
     * @Param Long companyId
     * @Return OtherCost
     * @Date 2021/7/16 11:22
     */
    @Query("match (c:Company)-[r:HAS_OTHER_COST]->(oc:OtherCost) where ID(c) = {companyId} return oc")
    OtherCost getByCompanyId(@Param("companyId") Long companyId);

    /**
     * @Description 企业缴费其他费用绑定企业
     * @Param Long companyId, Long id
     * @Return
     * @Date 2021/7/16 11:21
     */
    @Query("match (c:Company),(oc:OtherCost) where ID(c) = {companyId} and ID(oc) = {id} create (c)-[r:HAS_OTHER_COST]->(oc)")
    void bindCompany(@Param("companyId") Long companyId, @Param("id") Long id);

    /**
     * @Description 根据企业id解绑并删除企业缴费其他费用
     * @Param Long companyId
     * @Return
     * @Date 2021/8/17 17:46
     */
    @Query("match (c:Company)-[r:HAS_OTHER_COST]->(oc:OtherCost) where ID(c) = {companyId} delete r, oc")
    void unbindAndDelete(@Param("companyId") Long companyId);
}
